import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] array = new int[n];

        for (int i = 0; i < n; i++) {
            array[i] = scanner.nextInt();
        }

        Solution solution = new Solution();
        int[] res = solution.getSneakyNumbers(array);
        Arrays.toString(res);
    }
}

class Solution {
    public int[] getSneakyNumbers(int[] nums) {
        int[] res = new int[2];
        int[] array = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            array[nums[i]]++;
            if(array[nums[i]] >= 2){
                if(res[0] == 0){
                    res[0] = nums[i];
                }else{
                    res[1] = nums[i];
                }
            }
        }
     return res;
    }
}